import {ProjectOptions} from "@vue/cli-service/types/ProjectOptions";
const pkg = require('./package.json');
const AutoDllPlugin = require('autodll-webpack-plugin');
const path = require('path');
type Env = { [props: string]: any };
const processEnv: Env = process.env || {};
const resolve = dir => path.join(__dirname, dir);
const isProd = processEnv.NODE_ENV === 'production';
const config: ProjectOptions = {
    transpileDependencies:["vijay-util"],
    devServer: {
        // proxy: {
        //     '/proxy': {
        //         //要访问的跨域的api的域名
        //         target: 'http://dev-sdpb-admin-api.fulugame.cn',
        //         ws: false,
        //         secure:false, // 使用的是http协议则设置为false，https协议则设置为true
        //         changOrigin: true,
        //         pathRewrite: {
        //             '^/proxy': '/'  //必须这样写
        //         }
        //     }
        // }
    },
    publicPath: isProd ? "./" : "",
    configureWebpack: {
        entry: "./src/main.ts",
        resolve: {
            alias: {
                '@': resolve('src'),
                'assets': resolve('src/assets')
            },
        },
        module: {
            rules: [{
                test: /\.ts$/,
                loaders: [{
                    loader: 'ts-loader', options: {
                        transpileOnly: true,
                        appendTsSuffixTo: ['\\.vue$'],
                        happyPackMode: true
                    }
                }, {
                    loader: 'cache-loader',
                    options: {
                        cacheDirectory: resolve("node_modules/.cache/ts-loader"),
                        cacheIdentifier: Math.random().toString(16).substr(2)
                    }
                }]
            }]
        }
    },
    productionSourceMap: false,
    chainWebpack: (config) => {

        config.optimization.runtimeChunk('single')
        config.resolve.extensions.prepend('.ts');
    },
};

module.exports = config;
